package com.lwx.leetcode.offer.dp;

public class Offer14OneRecursive {
    public static void main(String[] args) {
        Offer14OneRecursive o = new Offer14OneRecursive();
        int ret = o.cuttingRope(10);
        System.out.println(ret);
    }
    public int cuttingRope(int n) {
        //dp[i]表示长度为i的绳子的最大乘积
        if(n<=1){
            return 0;
        }
        int[] dp = new int[n+1];
        dp[0] = 0;
        dp[1] = 0;
        for (int i = 2; i <= n; i++) {
            for (int j = 1; j <i ; j++) {
                dp[i] = Math.max(dp[i],Math.max(j*dp[i-j],j*(i-j)));
            }

        }
        return dp[n];
    }
}
